﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.IO;
public partial class WebRequest_Post_提交指定数据到页面 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //string Login Data
        string str登錄資料 = "&method=login&gameType=&forward=&username=" + System.Web.HttpUtility.UrlEncodeUnicode(text用户名.Text.Trim()) + "&password=" + System.Web.HttpUtility.UrlEncodeUnicode(Text密碼.Text.Trim()) + "&code=" ;
        ///设定登錄網址
        System.Net.HttpWebRequest Myrequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://passport.webgame.com.cn/chklogin.do");

        Myrequest.Referer = "http://passport.webgame.com.cn/login.do";//设定来源 用于
        Myrequest.Timeout = 6000;
        Myrequest.ContentType = "application/x-www-form-urlencoded"; //設定類型
        Myrequest.Method = "POST";//POST發送資料
        Myrequest.ContentLength = str登錄資料.Length;
        Myrequest.UserAgent = "Mozilla/4.0   (compatible;   MSIE   5.01;   Windows   NT   5.0)";
        //转成文件流
        StreamWriter oStreamWriter = new StreamWriter(Myrequest.GetRequestStream());
        oStreamWriter.Write(str登錄資料);
        oStreamWriter.Close();
        System.Net.HttpWebResponse oResponse = (System.Net.HttpWebResponse)Myrequest.GetResponse();



        System.IO.StreamReader MyStreamRead = new System.IO.StreamReader(oResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));

        txt内容.InnerHtml = MyStreamRead.ReadToEnd().ToString();
    }
}
